Skip to content

Conversation

@jp-pino
Copy link

@jp-pino jp-pino commented Sep 1, 2025

As mentioned in issue #216 some deprecated code has been removed from asio, making builds fail on boost >= 1.87. This is my attempt to fix this and try to improve the GitHub action to test more versions of Boost on each OS. Changes to the GitHub action were required to make sure that my changes remained backwards compatible.

I'm not an expert on what's going on under the hood in azmq but I just went through every part of the code that wasn't building and looked for the recommended alternative. Any feedback is appreciated.

We rely on azmq for some of our projects, so getting this fixed is of great interest to us.

I've removed the actions running on macos-11, macos-12 and ubuntu-20.04 since those runners have been deprecated. And I've added macos-13, macos-14, macos-15 and ubuntu-24.04 to the matrix, since those are the currently supported versions.

Some OS/Boost combinations that weren't being tested before still won't build (mostly macOS), so I would appreciate some help with this. I'm not sure how much of a priority this is for you. They could also be added to the exclusion list in the action.

Closes #216

@cbrl
Copy link

cbrl commented Oct 13, 2025

The failure that's happening with Ubuntu + Boost 1.70 might be expected: boostorg/thread#297. I think you'll see that with any version of Boost between 1.69 and 1.72.

Some of the macOS errors are caused by an incompatibility with Clang that was fixed in Boost 1.81: boostorg/numeric_conversion@50a1eae

@cbrl
Copy link

cbrl commented Oct 14, 2025

Anecdotally, I can say that I also haven't had any issues with these changes on Windows 11 with Boost 1.89.

The only problem I've had, which is an existing issue in the master branch, is that the async functions added in #195 don't compile when using some newer Asio completion token types. For example, azmq::async_send(socket, buffers, asio::deferred) will give a compilation error due to the usage of BOOST_ASIO_INITFN_RESULT_TYPE in the function signature.

It looks like Asio's async operations now use the return type of async_initiate directly instead of the result macro. For example, the signature of azmq::async_send might be

template<class CompletionToken, class ConstBufferSequence>
auto async_send(azmq::socket &socket, ConstBufferSequence const &buffers, CompletionToken &&token)
-> decltype(
      boost::asio::async_initiate<CompletionToken, void(boost::system::error_code, size_t)>(
          std::declval<async_send_initiation<ConstBufferSequence>>(), token))

I don't know if this necessarily needs to be fixed in this PR, but it's worth noting.

@jp-pino jp-pino marked this pull request as draft October 16, 2025 11:50
@jp-pino
Copy link
Author

jp-pino commented Nov 4, 2025

The branch was getting too polluted with my attempts at making it work for all versions so I cleaned it up a little.

The failure that's happening with Ubuntu + Boost 1.70 might be expected: boostorg/thread#297.

I've given up on getting it to work for 1.70 because of the issues commented by @cbrl. The point of the PR is not to fix Boost, so I guess that's something we can live with.

One of the breaking changes is the deprecation of FindBoost module as described by policy CMP0167.

A simple solution is to use:

# OLD behavior is to use the FindBoost module from cmake
# NEW behavior is to use the Boost CMake provided config files
# Boost 1.70 and above can use the new behavior
if (POLICY CMP0167)
  cmake_policy(SET CMP0167 NEW)
endif()

This however will make all builds for Boost < 1.70 fail. Currently I'm manually specifying in the tests which version of the Policy to use with -DCMAKE_POLICY_DEFAULT_CMP0167={OLD|NEW}.

The policy does specify that in future versions of cmake the FindBoost module might be removed altogether. We could consider dropping support for Boost 1.68 (Release Notes) which is pretty outdated by now (2018) and always set the policy to NEW.

@jp-pino
Copy link
Author

jp-pino commented Nov 4, 2025

Some of the macOS errors are caused by an incompatibility with Clang that was fixed in Boost 1.81: boostorg/numeric_conversion@50a1eae

@cbrl Should we then test on macOS only from 1.81 onwards?

@cbrl
Copy link

cbrl commented Nov 11, 2025

@cbrl Should we then test on macOS only from 1.81 onwards?

Probably. That specific error I linked to happens in Clang 16+, so only starting with macOS 15. However, macOS versions <15 still have other various compile errors in earlier versions of the Boost libraries.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fails to build with Asio 1.33.0 / Boost 1.87

2 participants